package com.xxd.spring.boot.demo.hexinglei.exception;

import com.xxd.spring.boot.demo.hexinglei.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

public class MyExceptionHandler {
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result exceptionHAndler(MyException e){
        System.out.println("异常："+e.getMessage());
        Result result = new Result();
        result.setCode(e.getCode());
        result.setMessage(e.getMessage());
        return result;
    }
}
